package com.jin.controller;

import com.jin.config.MessageConfig.Message;
import com.jin.pojo.UserInfoLevel;
import com.jin.service.UserInfoLevelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "绑定用户等级和用户信息管理模块")
@RestController
@RequestMapping("/userInfoLevel")
@CrossOrigin
public class UserInfoLevelController {
    @Autowired
    UserInfoLevelService userInfoLevelService;

    @ApiOperation(value = "添加用户信息之后在添加此人的用户类型")
    @PostMapping("/insertUserInfoLevel")
    public Message insertUserInfoLevel(UserInfoLevel userInfoLevel) {
        return userInfoLevelService.insertUserInfoLevel(userInfoLevel)>0?Message.success("200").add("success"):Message.fail("400").add("fail");
    }


    @ApiOperation(value = "删除用户信息以后把此人对应的用户类型也删除")
    @DeleteMapping("/delUserInfoLevel")
    public Message delUserInfoLevel(Integer userInfoLevelId) {
        return userInfoLevelService.delUserInfoLevel(userInfoLevelId)>0?Message.success("200").add("success"):Message.fail("400").add("fail");
    }


    @ApiOperation(value = "修改用户信息对应的用户等级")
    @PutMapping("/updateUserInfoLevel")
    public Message updateUserInfoLevel(UserInfoLevel userInfoLevel) {
        return userInfoLevelService.updateUserInfoLevel(userInfoLevel)>0?Message.success("200").add("success"):Message.fail("400").add("fail");
    }
}
